--[[ 编码: WMS-28-10 名称: 盘点单-根据盘点计划新增盘点单-确定后 作者:HAN 日期:2025-1-29 级别:固定 (说明本段代码在项目中不太会变化) 函数: AfterClickOK 功能: -- 项目场景巨星二期料箱库,先做盘点计划,生成计划盘点的容器 -- 弹出【新增盘点单】页面,根据站点,计划盘点容器数量 创建盘点单 更改记录: --]] wms_count= require( "wms_count" ) -- 事件入口函数 function AfterClickOK ( strLuaDEID ) local nRet, strRetInfo local input_attrs nRet, input_attrs = m3.GetSysCurEditDataAttrs( strLuaDEID ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..input_attrs ) end local count_plan_no = lua.Get_StrAttrValue( input_attrs.S_CP_NO ) local cntr_num = lua.Get_NumAttrValue( input_attrs.CNTR_Num ) -- 计划盘点容器数量 local max_cntr_num = lua.Get_NumAttrValue( input_attrs.PC_CNTR_Num ) -- 未盘点容器数量 local station = lua.Get_StrAttrValue( input_attrs.S_STATION ) -- 盘点站台 -- 输入参数判断 if ( count_plan_no == '' ) then mobox.setInfo( strLuaDEID, "盘点计划号不能为空!") return end if ( cntr_num <= 0 ) then mobox.setInfo( strLuaDEID, "盘点容器数量必须大于0!") return end if ( cntr_num > max_cntr_num ) then mobox.setInfo( strLuaDEID, "盘点容器数量不能大于未盘点容器数量!") return end -- 获取盘点计划数据对象 local count_plan nRet, count_plan = m3.GetDataObjectByKey( strLuaDEID, "Count_Plan", "S_CP_NO", count_plan_no ) if ( nRet ~= 0 ) then mobox.setInfo( strLuaDEID, count_plan ) return end if ( count_plan.b_state ~= 2 ) then mobox.setInfo( strLuaDEID, "盘点计划'"..count_plan_no.."'的状态不是执行中,无法创建盘点单!" ) return end -- 创建【盘点单】2 表示是系统自动搬运 local count_method = 2 -- 系统搬运到站台进行盘点 nRet, strRetInfo = wms_count.Create_CountOrder_ByCountPlan( strLuaDEID, count_plan, count_method, station, cntr_num ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "wms_count.Create_CountOrder_ByCountPlan 失败! "..strRetInfo ) end end